Skip to content

Audit fixes: optimizer limits, safe workbook writes, time_limit handling - #3

Draft
matveygreschner wants to merge 4 commits into
mainfrom
manager/2026-12-05-audit-lows
Draft

matveygreschner wants to merge 4 commits into
mainfrom
manager/2026-12-05-audit-lows

Conversation

@matveygreschner

Copy link
Copy Markdown
Owner

Fixes from the 2026-12-05 audit (low-severity items).

  • optimize_mix guards its limits and flags plans the solver could not prove optimal.
  • Workbook output is protected: symlinked workbook paths are refused, symlinked parent folders are documented, and writes stay safe when two of them collide.
  • time_limit: errors show the real value, non-numeric values are rejected, numpy whole numbers are accepted.
  • Docs: horizon range corrected.
  • Tests: test_long_schedules_solve_quickly measures CPU time instead of wall time.

331 tests pass locally. QA review approved.

The test failed on a busy machine (10 to 13 s wall against an 8 s limit). Profiling the 19,000-debit solve
showed about 0.9 s of CPU under cProfile and 0.6 s wall when idle, so there is no code regression and no
clean speed-up to take. The assertion now uses process_time, which ignores time spent waiting for other
jobs but still catches a real slowdown.
optimize_mix: time_limit must be above 0 and at most 300 s per solve, horizon_weeks 1 to 520, with errors
that name the argument. Results gain a warnings list for any solve stopped at its time limit, a CAUTION first
summary line, and an optimal flag on each sensitivity row.

workbook: refuses a directory, and refuses to overwrite the workbook or its .cells.json unless force is
true. CI and release workflows pass force to rebuild the committed workbook.

Docs, skill references and CHANGELOG updated; vendored skill copies rebuilt.
… symlink workbook paths, fix horizon range in docs

Vendored skill copies and generated references rebuilt with scripts/build_skills.py.
…cept numpy time_limit

workbook: build in a scratch folder beside the target, then place with an exclusive create (no force) or an
atomic replace (force), so a file or link appearing after the checks is never written through. Symbolic link
as the file is still refused, with or without force. A symlinked containing folder is allowed on purpose
(macOS /tmp is one) and is now documented in the docstring, skill reference and CHANGELOG.

optimize_mix: time_limit accepts any real number (numpy int and float included); bool, str and None are
still refused. Regression tests for all three; vendored skill copies rebuilt.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant